<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class LoginScreen extends Screen implements IRenderable {
	
	protected $title;
	
//	protected $showTitle;
		
//	protected $animateMinimize;
//	protected $defaultMinimizeHeight;
//	protected $minimizeHeight;
//	protected $minimizeTime;
	
	protected $autoCenter = true;
	protected $autoSize = true;
	protected $maximized = false;
	protected $minimized = false;
	
//	protected $bodyColor;
//	protected $bodyConstructor;
//	protected $bodyDefaults;
//	protected $bodyStyle;
	
	protected $canDragReposition = false;
	protected $canDragResize = false;
//	protected $canFocusInHeaderButtons;
//	protected $dismissOnEscape;
//	protected $dismissOnOutsideClick;
	
//	protected $contentLayout;
	
//	protected $contentsType;
	
//	protected $footerControls;
//	protected $footerHeight;
	
//	protected $headerControls;
//	protected $headerIcon;
//	protected $headerIconDefaults;
//	protected $headerLabel;
//	protected $headerLabelDefaults;
//	protected $headerSrc;
//	protected $headerStyle;
	
//	protected $showBody;
	protected $showCloseButton = false;
//	protected $showFooter;
//	protected $showHeader;
//	protected $showHeaderBackground;
	protected $showHeaderIcon = false;
//	protected $showMaximizeButton;
	protected $showMinimizeButton = false;
//	protected $showResizer;
			
	protected $isModal = true;
//	protected $modalMaskOpacity;
//	protected $modalMaskStyle;
	protected $showModalMask = true;
	
	protected $items;
	
	/**
	 * Constructeur
	 */
	public function LoginScreen() {
		parent::Screen();
		
		$this->width 	= null;
		$this->height 	= null;
		
		$this->title = new ExpressionType('isc.LoginDialog.LOGIN_TITLE');
		
		$df = new DynamicForm('loginForm');
		$df->set('canSubmit',true);
		$df->set('saveOnEnter',true);
		
		$f = new HiddenItem('_authRequest',1);
		$df->addItem($f);
		
		$f = new TextItem('_username');
		$f->set('title',new ExpressionType('isc.LoginDialog.USERNAME_TITLE'));
		$f->set('wrapTitle',false);
		$df->addItem($f);
		
		$f = new PasswordItem('_password');
		$f->set('title',new ExpressionType('isc.LoginDialog.PASSWORD_TITLE'));
		$f->set('wrapTitle',false);
		$df->addItem($f);
		
		$f = new SubmitItem();
		$f->set('title',new ExpressionType('isc.LoginDialog.LOGIN_BUTTON_TITLE'));
		$f->set('wrapTitle',false);
		$df->addItem($f);
		
		$this->items[] = $df;
	}

	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return "Layout";
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}
	
	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		//
	}
	
	/**
	 * Implementation de display
	 * @see IScreen::display()
	 */
	public function render() {
		$this->scLog();
		
		$str_out = "<html>";
		$str_out.= "<head>";
		$str_out.= "<title>Login</title>";
		$str_out.= "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />";
		$str_out.= "<script type=\"text/javascript\">var isomorphicDir=\"".Config::getParams()->PATH_ISOMORPHIC."\";</script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_Core.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_Foundation.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_Containers.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_Grids.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_Forms.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_Calendar.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_RichTextEditor.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_DataBinding.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_MODULES."ISC_History.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_SKINS.Config::getParams()->SKIN."/load_skin.js\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_LOCALES."frameworkMessages_".Config::getParams()->LANG.".properties\" type=\"text/javascript\"></script>";
		$str_out.= "<script src=\"".Config::getParams()->PATH_GLYPHE."res/js/md5.webtoolkit.info.js\" type=\"text/javascript\"></script>";
		$str_out.= "</head>";
		$str_out.= "<body>";
		$str_out.= "<script>";
		
		$str_out.= "isc.Window.create({".$this->properties()."});";

		// Traitement de la console
		if (Config::getParams()->CONSOLE) {
			$con = new Console('#console#', '- CONSOLE -');
			$str_out.= $con->render();
		}

		$str_out.= "</script>";
		$str_out.= "</body>";
		$str_out.= "</html>";

		echo $str_out;
	}
}
?>